﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            sra2();
        }
        static void sra()
        {
            Console.WriteLine("请输入正方形边长");
            int s = int.Parse(Console.ReadLine());
            for (int i = 1; i<=s; i++)
            {
                for (int j = 1; j <=s; j++)
                {
                    Console.Write("*"+" ");
                }
                Console.ReadLine();
            }

        }
        static void sra1()
        {
            string[,] arr = new string[9, 9];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    arr[i, j] = (i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1) + "\t";
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j]);
                }
                Console.WriteLine();
            }
            Console.ReadLine();
        }
        static void sra2()
        {
            Console.WriteLine("请输入正方形的边长");
            int a = int.Parse(Console.ReadLine());
            string[,] arr = new string[a, a];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if ((i == 0 || j == a - 1) || (j == 0 || i == a - 1))
                    {
                        arr[i, j] = "*";
                    }
                    else
                    {
                        arr[i, j] = " ";
                    }
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    Console.Write(arr[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
    }
   
}
